<template>
  <div class="auxiliarys-box-parent">
    <div
      v-for="item in props.Auxiliaryslist"
      :key="item.id"
      class="auxiliarys-box"
      :style="{ backgroundColor: props.imgBackground }"
    >
      <div class="auxiliarys-name-else">{{ item.name }}</div>
      <div class="auxiliarys-subTitle-else" v-if="item.subTitle">——{{ item.subTitle }}</div>
      <div class="unit_box_right_content" v-if="item.description">
        <div :class="item.coverUrl ? 'description-box' : 'description-onlytext'">
          <textMax
            v-if="item.description"
            :name="item.name"
            :subTitle="item.subTitle"
            :remarks="item.description"
            :tip="'全部'"
            :id="item.id"
            :title="item.text"
            :color="colorList5[store.styleInfo.colorType - 1].themeColor"
            :iconColor="colorList5[store.styleInfo.colorType - 1].shmentColor"
            :iconBorderColor="colorList5[store.styleInfo.colorType - 1].auxiliaryColor"
          />
        </div>
      </div>
      <div class="tdesign-demo-image-viewer__base" v-if="item.coverUrl">
        <t-image-viewer :images="[item.coverUrl]">
          <template #trigger="{ open }">
            <div class="tdesign-demo-image-viewer__ui-image">
              <img
                v-if="item.coverUrl"
                @click="open"
                alt=""
                :src="item.coverUrl"
                class="image tdesign-demo-image-viewer__ui-image--img auxiliarys-coverUrl t-image--fit-cover t-image--position-center"
              />
            </div>
          </template>
        </t-image-viewer>
      </div>
      <div>
        <div class="video-box" v-if="item.video && item.video.url">
          <playVideo :name="item.video.name" :url="item.video.url" />
        </div>
        <div class="audio-box" v-if="item.audio && item.audio.url">
          <playAudio
            playColor=""
            :name="item.audio.name"
            :url="item.audio.url"
            :nameColor="colorList5[store.styleInfo.colorType - 1].themeColor"
            :iconColor="colorList5[store.styleInfo.colorType - 1].themeColor"
            :timeColor="colorList5[store.styleInfo.colorType - 1].themeColor"
            :background="colorList5[store.styleInfo.colorType - 1].shmentColor"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
// @ts-nocheck
import { useRouter, useRoute } from 'vue-router';
import { auxiliarysList } from '@/api/templates/templates';
import { useProjectStore } from '@/store';
import { ref, watch, nextTick } from 'vue';
import textMax from './textMax.vue';
import playAudio from '@/components/templatePlay/auxiliarysAudio.vue';
import playVideo from '@/components/templatePlay/video.vue';
import playImg from '@/components/templatePlay/image.vue';
import { urls } from '@/utils/request/upload';
import { colorList5 } from '../../../../data';
import arrowLeft from '../../../components/arrowLeft.vue';
import arrowRight from '../../../components/arrowRight.vue';
import { MessagePlugin } from 'tdesign-vue-next';

const emit = defineEmits(['emitExhibits']);
const props = defineProps({
  Auxiliaryslist: {
    type: Object,
  },
  moduleId: {
    type: Number,
  },
  titleColor: {
    type: String,
    default: '#333333',
  },
  maxLen: {
    type: Number,
    default: 80,
  },
  imgBackground: {
    type: String,
    default: '#F0F3F6',
  },
  exhibitBackground: {
    type: String,
    default: '#F0F3F6',
  },
  subtitleColor: {
    type: String,
    default: 'rgba(51, 51, 51, 1)',
  },
});
const list = ref([]);
const store = useProjectStore();
const router = useRouter();
const route = useRoute();

const pathExhibits = (moduleId: number, showpieceid: number) => {
  emit('emitExhibits', moduleId, showpieceid);
};

// const init = async () => {
//   try {
//     let res = await auxiliarysList(localStorage.getItem('projectId'), props.moduleId, {
//       c: route.meta.loopType ? 1 : 0,
//     });
//     list.value = res.data;
//     list.value.forEach((item) => {
//       item.current = 1;
//     });

//     // setTimeout(() => {
//     nextTick(() => {
//       // var dom = document.getElementById('unit-box-scroll');
//       // dom.scrollIntoView();
//       const ele = document.getElementById('timeAxis-child-box-id'); // 获取元素
//       const top = ele.offsetTop - 140; // 获取元素距离文档顶部的距离
//       window.scrollTo({
//         top: top,
//       });
//     });
//     // }, 50);
//   } catch (err) {}
// };
const addCurrent = (num: number, item: any) => {
  // if (item.current === 0 && num < 0) {
  //   MessagePlugin.warning('暂无上一个展品');
  //   return;
  // }
  // // console.log(item.current, item.showpieces.length);
  // if (item.current === item.showpieces.length - 1 && num > 0) {
  //   MessagePlugin.warning('暂无下一个展品');
  //   return;
  // }
  // console.log(item);
  // item.current += num;
  // item.currentWidth += -296 * num;
  // console.log(item.current);
  // var imgItemImage = document.getElementById(`exhibits${item.id}`);
  // imgItemImage.style.transform = `translateX(${item.currentWidth}px)`;
};
</script>

<style scoped lang="less">
.auxiliarys-box {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-top: 50px;
  margin-top: 50px;
  padding-bottom: 80px;
  background: url('https://static.jiyi.show/template/template5/auxiliarysBG.png') center / 717px 476px;
  > div {
    margin: auto;
  }
}
.auxiliarys-box-parent {
}
:deep(.bbb) {
  font-size: 18px !important;
}
.description-box {
  margin-bottom: 26px;
  // margin-left: 50px;
  // height: 446px;
  // padding-top: 58px;
}
.content-text-heard {
  :deep(span) {
    font-size: 18px !important;
  }
}
.video-box {
  width: 1180px;
  margin: auto;
  margin-top: 40px;
  :deep(.d-player-wrap) {
    height: 400px;
  }
}
.audio-box {
  width: 1180px;
  margin: auto;
  margin-top: 40px;
}
:deep(.t-slider__rail) {
  height: 2px;
}
:deep(.t-slider__button) {
  width: 10px;
  height: 10px;
  background: rgba(38, 41, 51, 1);
  border: none;
}
:deep(.t-slider__button:hover) {
  width: 12px;
  height: 12px;
  background: rgba(38, 41, 51, 1);
  border: none;
}
:deep(.t-slider__track) {
  height: 2px;
  background: rgba(38, 41, 51, 1);
}
.exhibits-box {
  display: flex;
  flex-direction: column;
  width: 1180px;
  // padding-bottom: 50px;
  margin-top: 40px;
}
.exhibits-item {
  display: flex;
  width: 100%;
  height: 421px;
  margin-top: 12px;
  .img-box {
    display: block;
    width: 436px;
    height: 421px;
    cursor: pointer;
  }
}
.exhibits-item-right {
  display: flex;
  flex-direction: column;
  width: 664px;
  padding-left: 68px;
  height: 100%;
  flex: 1;
}
.exhibits-item-right-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  // margin-bottom: 24px;
}
.right-top-name-parent {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.exhibits-item-right-top-name {
  font-family: 'SourceHanSerifCN-Bold';
  width: 100%;
  font-size: 28px;
  line-height: 34px;
  color: #333;
  // text-align: center;
}
.iconfonts {
  cursor: pointer;
  font-size: 24px;
  color: #333;
}
.exhibits-item-right-description {
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5; /* 这里是超出几行省略 */
  overflow: hidden;
  margin-top: 26px;
  span {
    font-family: SourceHanSerifCN;
    font-size: 16px;
    line-height: 30px;
    color: #333;
  }
}
.item-mg {
  margin-top: 60px;
}
:deep(.d-slider .d-slider__runway .d-slider__preload) {
  background: rgba(255, 255, 255, 0.81);
}

.t-row {
  margin-top: 26px;
  margin-bottom: 0;
  color: #333;
  font-family: SourceHanSerifCN;
  font-size: 16px;
  font-style: normal;
  line-height: 24px; /* 150% */
}
.exhibit-left {
  color: #333;
  text-align: center;
  font-family: PingFang SC;
  font-size: 14px;
  opacity: 0.4;
  line-height: 22px; /* 157.143% */
}

.center-exhibit {
  width: 860px;

  margin: auto;
  margin-bottom: 50px;
  overflow: hidden;
  > div {
    display: flex;
  }
}

.icon-box {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-top: 114px;
  cursor: pointer;
  :deep(.iconfonts) {
    color: #fff !important;
    font-size: 20px !important;
  }
}
.auxiliarys-box-else {
  flex: 1;
}
.unit_box {
  width: 1180px;
  margin: 0 auto;
  // min-height: 435px;
  display: flex;
  .unit_box_left {
    width: 580px;
    height: 100%;

    border-right: none;
    position: relative;
  }

  .unit_box_right {
    width: 1180px;
    flex: 1;
    height: 100%;

    // padding: 3px;
  }
}
.unit_box_right_content {
  width: 1180px;
  height: 100%;
  margin-top: 40px !important;
  // padding: 118px 76px 117px 53px;
  font-size: 16px;
  line-height: 32px;
  font-family: SourceHanSerifCN;
  color: rgba(0, 0, 0, 0.7);
  :deep(.btnWord) {
    color: rgba(0, 0, 0, 1) !important;
  }
  :deep(.tj) {
    text-indent: 2em;
  }
  display: flex;
  justify-content: center;
  align-items: center;
  > img {
    width: 573px;
    height: 414px;
  }
}
.tdesign-demo-image-viewer__base {
  // width: 1180px;
  // max-height: 399px;
  object-fit: contain;
  margin-top: 0px !important;
}
.only-coverurl {
  padding-top: 33px;
  text-align: center;
  // min-height: 420px;
}
.auxiliarys-name-else {
  width: 1180px;
  color: #333;
  text-align: center;
  font-family: 'SourceHanSerifCN-Bold';
  font-size: 24px;
  line-height: 32px; /* 133.333% */
}
.auxiliarys-subTitle-else {
  width: 1180px;
  color: #333;
  text-align: center;
  font-family: SourceHanSerifCN;
  font-size: 18px;
  font-style: normal;
  line-height: 32px; /* 177.778% */
  margin-top: 10px !important;
}
.image {
  margin-top: 0px;
  height: 580px !important;
  width: 1180px !important;
  object-fit: contain;
  background: #b38952;
}
.image-bg3 {
  // src\assets\templateImg\auxiliarysExhibitBG1.png
  margin: 0 20px;
  background: url('@/assets/templateImg/auxiliarysExhibitBG1.png') center / 100% 100% no-repeat;
}
.image-bg2 {
  margin: 0 20px;
  background: url('@/assets/templateImg/auxiliarysExhibitBG2.png') center / 100% 100% no-repeat;
}
.image-bg1 {
  margin: 0 20px;
  background: url('@/assets/templateImg/auxiliarysExhibitBG3.png') center / 100% 100% no-repeat;
}
.exhibits-box3 {
  display: flex;
  margin-top: 56px;
  position: relative;
  width: 1293px;
  height: 450px;
  overflow: hidden;
  .exhibits-item0 {
    position: absolute;
    left: 90px;
  }
  .exhibits-item1 {
    position: absolute;
    left: 440px;
    width: 411px;
  }
  .exhibits-item2 {
    position: absolute;
    left: 887px;
  }
  .exhibits-item4 {
    position: absolute;
    left: 1380px;
    opacity: 0;
  }
  .exhibits-item5 {
    position: absolute;
    left: -500px;
    opacity: 0;
  }
  // :deep(.icon-boxs) {
  //   margin-top: 168px;
  // }
  img {
    // width: 411px;
    // height: 396px;
    border-radius: 0;
  }
}
.exhibits-item3 {
  // width: 100%;
  position: relative;
  width: 312px;
  height: 312px;
  transition: all 0.3s;
}
.exhibits-image {
  width: 411px;
  height: 396px;
  text-align: center;
  transition: all 0.3s;
  img {
    width: 100%;
    height: 100%;
  }
}
.exhibits-image-name {
  width: 100%;
  color: #333;
  text-align: center;
  font-family: 'SourceHanSerifCN-Bold';
  font-size: 18px;

  line-height: 28px; /* 155.556% */
  text-align: center;
  margin-top: 16px;
  margin-left: 20px;
}
.exhibits-image2 {
  width: 312px;
  height: 312px;
  margin-top: 47px;

  img {
    width: 100%;
    height: 100%;
  }
}
.arrowRight {
  position: absolute;
  right: 0px;
  top: 192px;
}
.arrowLeft {
  position: absolute;
  left: 0px;
  top: 192px;
}
.tdesign-demo-image-viewer__ui-image {
  img {
    width: 100%;
    height: 100%;
    border-radius: 4px;
  }
}
</style>
